<?php
/**
 *作用：统计各节点的平均命中率
 */

require("./Config.php");
$mem = new Memcache();

$gets = 0;
$hits = 0;

foreach($_memserv as $k=>$s){
    $mem->connect($s['host'],$s['port']);
    $res = $mem->getstats();
    $gets += $res['cmd_get'];
    $hits += $res['get_hits'];
}
//统计命中率
$rate = 1;   //命中率初始值
if($gets > 0){
    $rate = $hits / $gets;
}

echo $rate;